package net.qiqbframework.commandhandling;


import net.qiqbframework.common.Registration;
import net.qiqbframework.messaging.intercepting.MessageDispatchInterceptorSupport;
import net.qiqbframework.messaging.MessageHandler;

import javax.annotation.Nonnull;
import java.util.List;

public interface CommandBus extends MessageHandlerInterceptorSupport<CommandMessage<?>>, MessageDispatchInterceptorSupport<CommandMessage<?>> {


    <C> void dispatch(@Nonnull CommandMessage<C> command);


    <C, R> void dispatch(@Nonnull CommandMessage<C> command, @Nonnull CommandCallback<? super C, ? super R> callback);

    void batchDispatch(@Nonnull List<CommandMessage<?>> commandMessages );

    Registration subscribe(@Nonnull String commandName, @Nonnull CommandMessageHandler handler);
}
